package com.example.media_sample

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.etc.stlibrary.MediaShareManager
import com.etc.stlibrary.callback.MediaActionCallBack
import com.etc.stlibrary.enity.MediaConfig
import com.etc.stlibrary.view.MediaPublicFragment

class MediaPublicActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_media_publice)
        var fragment: MediaPublicFragment? = null
        fragment = MediaPublicFragment.newInstance(mediaConfig = MediaConfig().apply {
            mediaTitle = "这是标题"
            maxPicCount = 10
            mediaType = MediaShareManager.MEDIATYPE.VIDEO
            mediaSourceLists =
                arrayListOf("https://fyoss-test.fangyou.com/mp4_230913131d8f07812965d0e7e116bcaddf54f4ade28232f7")
            fileProviderAuthority = "${packageName}.fileproviderdy"


//            mediaSourceLists =
//                arrayListOf("https://fyoss-test.fangyou.com/file_230907169ddbdd7e13d72f391e5065eea9b4880a0e23e275")
        })
        supportFragmentManager.beginTransaction().apply {
            replace(
                R.id.fl,
                fragment
            )

            commitAllowingStateLoss()
        }

        MediaActionCallBack.onSubmitAction = {
//            toast("分享自媒体前")
        }

        //需要自己在分享前加业务 写这个回调， 不然不需要
        MediaActionCallBack.onPreShareCallBack = { shareId, title, mediaPlatform ->
            /**
             * 传此接口 就打断写自己业务相关的  比如 分享的视频和房源绑定关系
             *
             *  httpBindHouse(HouseInfo,callback={
            fragment.shareMedia(shareId,mediaPlatform)
            })
             */

            fragment.shareMedia(shareId, mediaPlatform)

        }
    }
}